﻿using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using NetMicro.Core.Helper;
using NetMicro.Trace.Enums;

namespace NetMicro.Trace.Options
{
    /// <summary>
    /// 日志配置
    /// </summary>
    public class LoggingOption
    {
        /// <summary>
        /// 日志过滤
        /// </summary>
        public Dictionary<string, LogLevel> LogLelvel { get; set; } = new Dictionary<string, LogLevel>();

        /// <summary>
        /// 服务名称
        /// </summary>
        public string ServiceName { get; set; } = App.Configuration["applicationName"] ?? "default-app".ToLower().Replace('.', '_');
        /// <summary>
        /// 日志输出类型
        /// </summary>
        public WriteToType WriteToType { get; set; } = WriteToType.TextWithConsole;

        /// <summary>
        /// 日志存储地址
        /// </summary>
        public string LogPath { get; set; } = $"/opt/logs/{App.Configuration["applicationName"] ?? "default-app".ToLower().Replace('.', '_')}";

        /// <summary>
        /// 错误邮件发送
        /// </summary>
        public ErrorEmailOption ErrorEmail { get; set; } = new ErrorEmailOption();

    }

    /// <summary>
    /// 错误邮件发送
    /// </summary>
    public class ErrorEmailOption
    {

        /// <summary>
        /// 是否发送邮件
        /// </summary>
        public bool IsWriteToEmail { get; set; } = false;

        /// <summary>
        /// 邮件主题
        /// </summary>
        public string Subject { get; set; } = $"数字化平台--系统[{App.Configuration["applicationName"]}-{App.EnvironmentName}]出错误了";

        /// <summary>
        /// SMTP电子邮件服务器
        /// </summary>
        public string MailServer { get; set; }

        /// <summary>
        /// 发送者地址
        /// </summary>
        public string FromEmail { get; set; }

        /// <summary>
        /// 授权码
        /// </summary>
        public string AuthCode { get; set; }

        /// <summary>
        /// 设置用于连接的端口
        /// </summary>
        public int Port { get; set; }

        /// <summary>
        /// 接收者地址
        /// </summary>
        public string ToEmail { get; set; }
    }
}
